package com.zhn.shortlink.project.controller;

import com.zhn.shortlink.project.common.convention.result.Result;
import com.zhn.shortlink.project.common.convention.result.Results;
import com.zhn.shortlink.project.service.UrlTitleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class UrlTitleController {

    private final UrlTitleService urlTitleService;
    @GetMapping("/api/short-link/v1/title")
    public Result<String> getUrlTitle(@RequestParam("url") String url){
        String urlTitle = urlTitleService.getUrlTitle(url);
        return Results.success(urlTitle);
    }

}
